<template>
	<view class="status-bar"></view>
	<view class="">
		<uni-swipe-action>
			<nodata v-if="isdata"></nodata>
			<uni-swipe-action-item
				:right-options="options"
				:show="isOpened"
				@change="change"
				@click="bindClick(item,index)"
				v-for="(item,index) in info" :key="index"
			>
			<view @click="navto('/pages/index/detail?id='+item.link_id)" class="border-bEDEDED pb30 mt30 mr30 ml30">
				<view class="flex-ju-b posire">
					<view class="flex-a-i">
						<image class="image wh76-76 ra76 mr20" :src="item.user.avatar?item.user.avatar:'/static/mo.png'"></image>
						<view>
							<view>{{item.user.nickname}}</view>
							<view class="size26 color999 mt5">{{item.result}}</view>
						</view>
					</view>
					<view>
						<!-- <image class="image wh76-76 " src="../../static/aaa.png"></image> -->
					</view>
				</view>
				<view class="ml96 size26">
					<view class="mt25">{{item.content}}</view>
				</view>
			</view>
				
			</uni-swipe-action-item>
		</uni-swipe-action>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isdata:false,
				info:[],
				page:1,
				options: [
					{
						text: '删除',
						style: {
							backgroundColor: '#FF3B30'
						}
					}
				],
			}
		},
		onLoad() {
			this.getlist()
			
			
		},
		onReachBottom() {
			this.page++
			this.getlist()
		},
		methods: {
			bindClick(item,index){
				this.http('/api/del_msg/'+item.id,{},'DELETE').then(res=>{
					uni.showToast({
						title:"删除成功",
						icon:"none"
					})
					this.info.splice(index,1)
					if(this.info.length){
						this.isdata=false
					}else{
						this.isdata=true
					}
				})
			},
			getlist(){
				this.http('/api/msg_list',{type:2,page:this.page,limit:20}).then(res=>{
					this.info = [...this.info,...res.data.list]
					if(this.info.length){
						this.isdata=false
					}else{
						this.isdata=true
					}
					
					var buser = uni.getStorageSync('user')
					buser.word_un_read=0
					uni.setStorageSync('user',buser)
				})
			},
			change(e){
				console.log(e)
			},
		}
	}
</script>


<style>

</style>
